/*
 * 获取手机基本信息
 */

import Vue from "vue";

export const getPhoneInfo = () => {
    uni.getSystemInfo({
        success: function(e) {
            const phoneModel = e.model;
            Vue.prototype.$isQyWx = () => !!e.environment;

            //区分微信环境、企业微信环境
            if (e.environment) {
                uni.setStorageSync("runEnvironment", e.environment);
                Vue.prototype.environment = e.environment;
            }
            console.log("是否企业微信打开 :>> ", !!e.environment);
            if (e.platform == "android") {
                Vue.prototype.CustomBar = e.statusBarHeight + 50;
                Vue.prototype.isIos = false;
            } else {
                Vue.prototype.CustomBar = e.statusBarHeight + 45;
                Vue.prototype.isIos = true;
            }
            let BottomBlackLineHeight = ""; //iphoneX底部一条黑线，有些页面要避开
            let iphoneXArr = ["iPhone X", "iPhone 11", "iPhone 11 Pro Max"];
            Vue.prototype.BottomBlackLineHeight = 0;
            iphoneXArr.forEach(function(item) {
                if (phoneModel.search(item) !== -1) {
                    Vue.prototype.BottomBlackLineHeight = 30;
                }
            });
            // #ifdef MP
            const custom = wx.getMenuButtonBoundingClientRect();
            // console.log('[胶囊位置]', custom);
            Vue.prototype.Custom = custom;
            Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
            // #endif
            Vue.prototype.conTop = e.statusBarHeight;
            // console.log('[屏幕宽度]',e.windowWidth);
            Vue.prototype.sysWidth = e.windowWidth;
            Vue.prototype.sysHeight = e.windowHeight;
        },
    });
};